package laugh.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import laugh.util.ValidateCodeUtil;

/**
 * 
*    
* 项目名称：LaughFactory   
* 类名称：ValidateCodeServlet   
* 类描述：   验证码服务Servlet
* 创建人：wizard   
* 创建时间：2012-3-30 下午03:17:04   
* 修改人：wizard   
* 修改时间：2012-3-30 下午03:17:04   
* 修改备注：   
* @version 0.9
*
 */
public class ValidateCodeServlet extends HttpServlet {

    private static final long serialVersionUID = -3698973601540589270L;

    public ValidateCodeServlet() {
        super();
    }

    public void destroy() {
        super.destroy();
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("image/jpeg");// 生成时的图像格式
        ServletOutputStream out = response.getOutputStream();
        ValidateCodeUtil.doIt(request, out);
        out.flush();
        out.close();
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }

    public void init() throws ServletException {
    }

}
